package ${servicePackage}.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ${pojoPackage}.entity.${className};
import ${pojoPackage}.param.${classOtherName}.*;
import ${pojoPackage}.vo.${classOtherName}.*;
import ${pojoPackage}.dto.${classOtherName}.*;
import ${servicePackage}.repository.in.${className}Repository;
import ${servicePackage}.service.in.${className}Service;
import ${corePackage}.domains.vo.PageResult;
import ${corePackage}.utils.ids.IdGenerator;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.List;

/**
* 【描 述】：${entityName}服务
* 【环 境】：J2SE 17
* 【详 细】：
*
*/
@Service
public class ${className}ServiceImpl implements ${className}Service {

private final ${className}Repository ${classOtherName}Repository;

public ${className}ServiceImpl(${className}Repository ${classOtherName}Repository) {
this.${classOtherName}Repository = ${classOtherName}Repository;
}


/**
* 创建${entityName}
*
* @param param
*/
@Override
public void create${className}(Create${className}Param param) {
${className} ${classOtherName} =new ${className}();
BeanUtils.copyProperties(param,${classOtherName});
Long id = IdGenerator.SNOW.generate();
${classOtherName}.setId(id);
${classOtherName}Repository.create(${classOtherName});
}

/**
* 修改${entityName}
*
* @param param
*/
@Override
public void edit${className}(Edit${className}Param param) {
Long id = param.getId();
${className} ${classOtherName} =${classOtherName}Repository.getByIdCheck(id);
BeanUtils.copyProperties(param,${classOtherName});
${classOtherName}Repository.edit(${classOtherName});
}

/**
* 移除${entityName}
*
* @param id
*/
@Override
public void remove${className}(Long id) {
${classOtherName}Repository.removeById(id);
}

/**
* 启动/禁用${entityName}
*
* @param id
*/
@Override
public void enabled${className}(Long id) {
${className} ${classOtherName} =${classOtherName}Repository.getByIdCheck(id);
${classOtherName}.setIsDisable(!${classOtherName}.getIsDisable());
${classOtherName}Repository.edit(${classOtherName});
}

/**
* 获取${entityName}详情
*
* @param id
* @return
*/
@Override
public Get${className}Vo get${className}(Long id) {
${className} ${classOtherName} =${classOtherName}Repository.getByIdCheck(id);
Get${className}Vo vo=new Get${className}Vo();
BeanUtils.copyProperties(${classOtherName},vo);
return vo;
}

/**
* 获取${entityName} 列表
*
* @param param
* @return
*/
@Override
public PageResult< Get${className}ListVo> get${className}List(Get${className}ListParam param) {

Select${className}Dto dto = new Select${className}Dto();
BeanUtils.copyProperties(param,dto);
Page< ${className} > page = ${classOtherName}Repository.select${className}(dto);
List< ${className} > ${classOtherName}List = page.getRecords();
List< Get${className}ListVo > list= new ArrayList<>();
for (${className} ${classOtherName} : ${classOtherName}List) {
Get${className}ListVo vo=new Get${className}ListVo();
BeanUtils.copyProperties(${classOtherName},vo);

list.add(vo);
}
return new PageResult<>(list,page);

}

/**
* 获取${entityName}下拉列表
*
* @param param
* @return
*/
@Override
public List< Get${className}DownListVo > get${className}DownList(Get${className}DownListParam param) {
${className} po = new ${className}();
if (param != null) {
BeanUtils.copyProperties(param, po);
}
List< ${className} > ${classOtherName}List = ${classOtherName}Repository.getListByEntity(po);

List< Get${className}DownListVo > list = new ArrayList<>();
for (${className} ${classOtherName} : ${classOtherName}List) {
Get${className}DownListVo vo=new Get${className}DownListVo();
BeanUtils.copyProperties(${classOtherName},vo);
list.add(vo);
}
return list;
}


}



